package com.lry.event;

import com.lry.bean.ExceptionNotice;
import com.lry.send.INoticeSendComponent;
import lombok.extern.slf4j.Slf4j;

import java.util.List;
import java.util.concurrent.Executor;

@Slf4j
public class AsyncNoticeSendListener extends AbstractNoticeSendListener{


    private Executor eaTaskExecutor;

    public AsyncNoticeSendListener(List<INoticeSendComponent<ExceptionNotice>> list, Executor eaTaskExecutor) {
        super(list);
        this.eaTaskExecutor = eaTaskExecutor;
    }

    @Override
    public void onApplicationEvent(ExceptionNoticeEvent exceptionNoticeEvent) {
        eaTaskExecutor.execute(()->{
            log.debug("消息异步发送"+exceptionNoticeEvent.getExceptionNotice());
            send(exceptionNoticeEvent.getExceptionNotice());
        });
    }

}
